<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class MasterWallet extends BaseModel
{
    protected $table = 'master_wallet';

    const CREATED_AT = 'add_time';
    const UPDATED_AT = 'upd_time';

    protected $dateFormat = 'U';

    protected $fillable = [
        'master_id',
        'balance',
    ];

    protected $casts = [
        'assure_fund' => 'double',
        'balance' => 'double',
        'last_trade_balance' => 'double',
        'last_trade_amount' => 'double',
    ];

    /**
     * 余额文字
     */
    public function getBalanceTextAttribute()
    {
        return sprintf('%0.2f',$this->balance);
    }

    /**
     * 诚信保证金文字
     */
    public function getAssureFundTextAttribute()
    {
        return sprintf('%0.2f',$this->assure_fund);
    }
}
